import babel from '@babel/core';
const sourceCode = `<div id="root">hello world</div>`;

// https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx
// @babel/plugin-syntax-jsx Babel 有效的解析 JSX 语法

// https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-react-jsx
// @babel/plugin-transform-react-jsx 内部会调用 @babel/plugin-syntax-jsx  将jsx转换为js

debugger;
const result = babel.transform(sourceCode, {
  // 经典模式
  plugins: [['@babel/plugin-transform-react-jsx', { runtime: 'automatic' }]],
});

// 自动引入函数 调用函数 不再需要 import React from 'react'
// import { jsx as _jsx } from "react/jsx-runtime";

// _jsx("div", {
//   id: "root",
//   children: "hello world",
// });

console.log(result.code);
